package com.power.result;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R OK() {
        return R.builder().code(CodeEnum.OK.getCode()).msg(CodeEnum.OK.getMsg()).data(null).build();
    }

    public static R OK(String msg) {
        return R.builder().code(CodeEnum.OK.getCode()).msg(msg).data(null).build();
    }

    public static R OK(String msg, Object data) {
        return R.builder().code(CodeEnum.OK.getCode()).msg(msg).data(data).build();
    }

    public static R OK(Object data) {
        return R.builder().code(CodeEnum.OK.getCode()).msg(CodeEnum.OK.getMsg()).data(data).build();
    }

    public static R FAIL() {
        return R.builder().code(CodeEnum.FAIL.getCode()).msg(CodeEnum.FAIL.getMsg()).data(null).build();
    }

    public static R FAIL(String msg) {
        return R.builder().code(CodeEnum.FAIL.getCode()).msg(msg).data(null).build();
    }

    public static R FAIL(int code, String msg) {
        return R.builder().code(code).msg(msg).data(null).build();
    }
}
